package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.PwdBean;
import com.lwj.liwanjia.impl.EditZfPwdView;
import com.lwj.liwanjia.model.EditZfPwdModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/12/4.
 */

public class EditZfPwdPresenter {
    private EditZfPwdView editZfPwdView;
    private EditZfPwdModel editZfPwdModel;

    public EditZfPwdPresenter(EditZfPwdView editZfPwdView) {
        this.editZfPwdView = editZfPwdView;
        editZfPwdModel = new EditZfPwdModel();
    }

    public void editZfPwd(String token, String oldPassword, String newPassword) {
        if (editZfPwdView != null) {
            editZfPwdModel.editPwd(token, oldPassword, newPassword, new Subscriber<PwdBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    editZfPwdView.showError((Exception) e);
                }

                @Override
                public void onNext(PwdBean pwdBean) {
                    editZfPwdView.editZfPwd(pwdBean);
                }
            });
        }
    }
}
